package com.iflytek.management.util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionManager;


public class MybatisUtil {
	
	private static SqlSessionManager sessionManager = null;
	
	// 简化接口代理流程	
	public static <T> T Prepare(Class<T> tClass) throws IOException {
		// 获得核心配置文件
        InputStream resourceAsStream = Resources.getResourceAsStream("SqlMapConfig.xml");
        // sessionManager自动 关闭session
        sessionManager = SqlSessionManager.newInstance(resourceAsStream);
        // 获取对应mapper
        T mapper = sessionManager.getMapper(tClass);
        		
        return mapper;
		
	}

}
